﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cspl.AnimalFight.Lib;
using Cspl.AnimalFight.Lib.Data;


namespace Cspl.AnimalFight.Main
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Welcome to Animal Battlefield");
            Console.WriteLine("=============================\n");

            BattleField battleField = new BattleField();

            Dog dog1 = new Dog
            {
                AnimalName = "Doggy",
                HP = 1000,
                DP = 150,
                AP = 300,
                Mood = DogMood.Bad

            };
            Dog dog2 = new Dog
            {
                AnimalName = "Dongki",
                HP = 500,
                DP = 150,
                AP = 250,
                Mood = DogMood.Good

            };

            Duck duck1 = new Duck
            {
                AnimalName = "Donald",
                HP = 1000,
                DP = 200,
                AP = 500
            };

            Horse horse1 = new Horse
            {
                AnimalName = "Horsi",
                HP = 200,
                DP = 300,
                AP = 100
            };

            Snake snake1 = new Snake
            {
                AnimalName = "Snaki",
                HP = 1000,
                DP = 100,
                AP = 300
            };

            battleField[dog1.AnimalName] = dog1;
            battleField[dog2.AnimalName] = dog2;
            battleField[snake1.AnimalName] = snake1;
            battleField[duck1.AnimalName] = duck1;
            battleField[horse1.AnimalName] = horse1;

            //battleField.Command("horse1", Commands.Attack, "snake1");
            string commandLine;
            string command = string.Empty;
            while (command != "Exit")
            {
                commandLine = System.Console.ReadLine();
                string[] commands = commandLine.Split(' ');
                command = commands[0];
                switch (command)
                {
                    case "Attack":
                        if (commands.Length < 3)
                        {
                            Console.WriteLine("Invalid command.");
                        }
                        else 
                        {
                            battleField.Command(commands[1], Commands.Attack, commands[2]);
                        }
                        break;
                    case "Defense":
                        if (commands.Length < 2)
                        {
                            Console.WriteLine("Invalid Command for defense.");
                        }
                        else
                        {
                            // Bug Fixed->empty the 3rd parameter string->Mohammad Nhasa
                            battleField.Command(commands[1], Commands.Defense, string.Empty);
                        }
                        break;
                    case "Escape":
                        if (commands.Length < 2)
                        {
                            Console.WriteLine("Invalid Command for escape.");
                        }
                        else
                        {
                            // bug fixed by Agni Pradharma
                            battleField.Command(commands[1], Commands.Escape, string.Empty);
                        }
                        break;
                    case "Exit":
                        Console.WriteLine("Exit the aplication.");
                        break;
                    default:
                        Console.WriteLine("Invalid Command.");
                        break;
                        
                }
            }
            Console.Read();
        }
    }
}
